var t = getApp();

Component({
    properties: {
        ok_subs_select: {
            value: null,
            type: Number
        },
        successLocation: {
            value: !1,
            type: Boolean
        }
    },
    observers: {
        successLocation: function(t) {
            this.setData({
                _successLocation: t
            });
        }
    },
    data: {
        parentActive: null,
        _successLocation: !1,
        subs_select: null,
        activeType: "",
        isshowO2oOptionMenu: !1,
        option: [],
        selectOption: [],
        isShowSubContent: !1
    },
    lifetimes: {
        attached: function() {
            console.log("筛选器==========="), this.getStoreSearchMenu();
        },
        detached: function() {}
    },
    methods: {
        onOptionsItemClick: function(t) {
            var e = t.currentTarget.dataset.item;
            if (this.data._successLocation) if (e.subs || this.data.parentActive != e.value) {
                if (e.subs) {
                    if (this.data.activeType == e.value && this.data.isShowSubContent) return void this.cloneFilter();
                    this.setData({
                        selectOption: e.child,
                        isShowSubContent: !0,
                        subs_select: this.data.ok_subs_select
                    });
                } else this.setData({
                    isShowSubContent: !1,
                    subs_select: null
                });
                this.setData({
                    activeType: e.value
                }), e.subs || "goods_show" == e.value ? "goods_show" == e.value && (this.setData({
                    parentActive: this.data.activeType
                }), this.triggerEvent("changeOptiones", {
                    tag: !0,
                    activeType: this.data.activeType,
                    subs_select: this.data.subs_select
                })) : (this.setData({
                    parentActive: this.data.activeType
                }), this.triggerEvent("changeOptiones", {
                    tag: !1,
                    activeType: this.data.activeType,
                    subs_select: this.data.subs_select
                }));
            } else this.resetFilter(); else wx.showToast({
                duration: 3e3,
                title: "定位中，请稍等...",
                icon: "none"
            });
        },
        getStoreSearchMenu: function() {
            var e = this, s = t.getNetAddresss("plugin.store-cashier.frontend.store.goods.get-store-search-praise");
            t._getNetWork({
                showToastIn: !1,
                url: s,
                success: function(t) {
                    var s = t.data;
                    if (1 == s.result) {
                        var a = [];
                        1 == s.data.is_category_ids && a.push({
                            text: "门店分类",
                            value: "classify",
                            subs: !0,
                            child: s.data.categories
                        }), 1 == s.data.is_distance && a.push({
                            text: "离我最近",
                            value: "distance",
                            subs: !0,
                            child: [ {
                                name: "1km内",
                                id: 1
                            }, {
                                name: "3km内",
                                id: 3
                            }, {
                                name: "5km内",
                                id: 5
                            }, {
                                name: "10km内",
                                id: 10
                            } ]
                        }), 1 == s.data.is_open_praise && a.push({
                            text: "好评优先",
                            value: "is_open_praise",
                            subs: !1
                        }), 1 == s.data.is_open_sales_volume && a.push({
                            text: "销量最高",
                            value: "is_open_sales_volume",
                            subs: !1
                        }), 1 == s.data.goods_show && a.push({
                            text: "优惠力度",
                            value: "goods_show",
                            subs: !1
                        }), e.setData({
                            option: a,
                            isshowO2oOptionMenu: !0
                        });
                    }
                },
                fail: function(t) {}
            });
        },
        onSubOptionsItemClick: function(t) {
            var e = this.data.subs_select == t.currentTarget.dataset.items.id ? null : t.currentTarget.dataset.items.id;
            this.setData({
                subs_select: e
            });
        },
        cloneFilter: function() {
            this.setData({
                isShowSubContent: !1
            });
        },
        resetFilter: function() {
            this.setData({
                subs_select: null,
                parentActive: null,
                isShowSubContent: !1
            }), this.triggerEvent("resetFilter", {});
        },
        filterData: function() {
            this.data.subs_select && this.setData({
                parentActive: this.data.activeType
            }), this.triggerEvent("changeOptiones", {
                tag: !1,
                activeType: this.data.activeType,
                subs_select: this.data.subs_select
            }), this.setData({
                isShowSubContent: !1
            });
        }
    }
});